#include "xg_private.h"
#include "xc_core.h"
-static int max_gpfn(int xc_handle, domid_t domid)
+static int nr_gpfns(int xc_handle, domid_t domid)
{
- return xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &domid);
+ return xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &domid) + 1;
}
int
xc_core_memory_map_t **mapp,
unsigned int *nr_entries)
{
- unsigned long p2m_size = max_gpfn(xc_handle, info->domid);
+ unsigned long p2m_size = nr_gpfns(xc_handle, info->domid);
xc_core_memory_map_t *map;
map = malloc(sizeof(*map));
xen_pfn_t *live_p2m_frame_list_list = NULL;
xen_pfn_t *live_p2m_frame_list = NULL;
uint32_t dom = info->domid;
- unsigned long p2m_size = max_gpfn(xc_handle, info->domid);
+ unsigned long p2m_size = nr_gpfns(xc_handle, info->domid);
int ret = -1;
int err;
}
/* Get the size of the P2M table */
- p2m_size = xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &dom);
+ p2m_size = xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &dom) + 1;
/* Domain is still running at this point */
if ( live )
unsigned long domain_get_maximum_gpfn(struct domain *d)
{
- return is_hvm_domain(d) ? d->arch.p2m.max_mapped_pfn : arch_get_max_pfn(d);
+ if ( is_hvm_domain(d) )
+ return d->arch.p2m.max_mapped_pfn;
+ /* NB. PV guests specify nr_pfns rather than max_pfn so we adjust here. */
+ return arch_get_max_pfn(d) - 1;
}
void share_xen_page_with_guest(
{
ASSERT(d->arch.paging.shadow.dirty_bitmap == NULL);
d->arch.paging.shadow.dirty_bitmap_size =
- (domain_get_maximum_gpfn(d) + (BITS_PER_LONG - 1)) &
- ~(BITS_PER_LONG - 1);
+ (domain_get_maximum_gpfn(d) + BITS_PER_LONG) & ~(BITS_PER_LONG - 1);
d->arch.paging.shadow.dirty_bitmap =
xmalloc_array(unsigned long,
d->arch.paging.shadow.dirty_bitmap_size / BITS_PER_LONG);